﻿using System.Collections.ObjectModel;
using System.Windows.Controls;
using VisionDesigner;
using VM.Controls;
using VM.Start.ViewModels.Dock;

namespace VM.Start.Views.Dock
{
    /// <summary>
    /// VisionView.xaml 的交互逻辑
    /// </summary>
    public partial class VisionView : UserControl
    {
        // 定义事件
        public event EventHandler<PointDataEventArgs>? PointDataSent;
        public event EventHandler<TrajectoryPointsEventArgs>? TrajectoryPointsGenerated;
        public CMvdAnnularSectorF _DrawArc;                                                     // 绘制圆弧
        public List<CMvdLineSegmentF> _DrawOutlineList = new List<CMvdLineSegmentF>();          // 绘制边缘点
        public List<CMvdRectangleF> _DrawRectangleFList = new List<CMvdRectangleF>();           // 绘制矩形框
        private List<CMvdPointSetF> _MatchOutlineList = new List<CMvdPointSetF>();              // 匹配轮廓列表
        public ObservableCollection<CMvdShape> _addedShapes = new ObservableCollection<CMvdShape>();  // 已经绘制添加的图形

        public VisionView()
        {
            InitializeComponent();
            this.DataContext = VisionViewModel.Ins;
            // 订阅 DisplayControl 的 PointDataSent 事件
            MainWindow.PointDataSent += OnDisplayControlPointDataSent; ;
            MainWindow.TrajectoryPointsGenerated += OnDisplayControlTrajectoryPointsGenerated;
        }

        private void OnDisplayControlTrajectoryPointsGenerated(object? sender, TrajectoryPointsEventArgs e)
        {
            TrajectoryPointsGenerated?.Invoke(this, e);
        }

        // 当 DisplayControl 的事件触发时，重新引发 VisionView 的事件
        private void OnDisplayControlPointDataSent(object? sender, PointDataEventArgs e)
        {
            PointDataSent?.Invoke(this, e); // 转发事件
        }

    }


}
